﻿namespace TreeViewMVVMInPlaceEditingDemo.InPlaceEdit.ViewModel
{
  using System.Collections.ObjectModel;
  using BusinessLib;

  /// <summary>
  /// This is the view-model of the UI.  It provides a data source
  /// for the TreeView (the FirstGeneration property), a bindable
  /// SearchText property, and the SearchCommand to perform a search.
  /// </summary>
  public class FamilyTreeViewModel
  {
    #region Data
    readonly ReadOnlyCollection<PersonViewModel> _firstGeneration;
    readonly PersonViewModel _rootPerson;
    #endregion // Data

    #region Constructor
    public FamilyTreeViewModel(Person rootPerson)
    {
      _rootPerson = new PersonViewModel(rootPerson);

      _firstGeneration = new ReadOnlyCollection<PersonViewModel>(new[] { _rootPerson });
    }

    #endregion // Constructor

    #region FirstGeneration

    /// <summary>
    /// Returns a read-only collection containing the first person 
    /// in the family tree, to which the TreeView can bind.
    /// </summary>
    public ReadOnlyCollection<PersonViewModel> FirstGeneration
    {
      get { return _firstGeneration; }
    }

    #endregion // FirstGeneration
  }
}